package net.sourceforge.web.easyui;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <h4>Tree Data Format</h4>
 * <p>
 * Every node can contains following properties:
 * </p>
 * <ul>
 * <li>id: node id, which is important to load remote data</li>
 * <li>text: node text to show</li>
 * <li>state: node state, 'open' or 'closed', default is 'open'. When set to
 * 'closed', the node have children nodes and will load them from remote
 * site</li>
 * <li>checked: Indicate whether the node is checked selected.</li>
 * <li>attributes: custom attributes can be added to a node</li>
 * 
 * <li>children: an array nodes defines some children nodes</li>
 * </ul>
 * sample data:
 * 
 * <pre>
 * [{
    "id":1,
    "text":"Folder1",
    "iconCls":"icon-save",
    "children":[{
        "text":"File1",
        "checked":true
    },{
        "text":"Books",
        "state":"open",
        "attributes":{
            "url":"/demo/book/abc",
            "price":100
        },
        "children":[{
            "text":"PhotoShop",
            "checked":true
        },{
            "id": 8,
            "text":"Sub Bookds",
            "state":"closed"
        }]
    }]
},{
    "text":"Languages",
    "state":"closed",
    "children":[{
        "text":"Java"
    },{
        "text":"C#"
    }]
}]
 * </pre>
 * 
 * tree node structure
 * 
 * @author alex
 *
 */
public class EasyuiTree {
	private String id;
	private String text;
	private String state;
	private boolean checked;
	private Map<String, Object> attributes;
	private List<EasyuiTree> children;
	private String iconCls;
	private String href;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public boolean isChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	public Map<String, Object> getAttributes() {
		return attributes;
	}

	public void setAttributes(Map<String, Object> attributes) {
		this.attributes = attributes;
	}

	public List<EasyuiTree> getChildren() {
		return children;
	}

	public void setChildren(List<EasyuiTree> children) {
		this.children = children;
	}

	public void addChild(EasyuiTree child) {
		if (this.children == null) {
			children = new ArrayList<EasyuiTree>();
		}
		children.add(child);
	}

	public String getIconCls() {
		return iconCls;
	}

	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}

	public String getHref() {
		return href;
	}

	public void setHref(String href) {
		this.href = href;
	}
}
